package main;

public class ArrayList implements Listable<Integer> {
    private Integer size;
    private Integer[] elements;

    private static final Integer DEFAULT_CAPACITY = 10;

    public ArrayList(Integer capacity) {
        capacity = capacity > DEFAULT_CAPACITY ? capacity : DEFAULT_CAPACITY;
        elements = new Integer[capacity];
    }

    private ArrayList() {
        this(DEFAULT_CAPACITY);
    }

    @Override
    public int size() {
        return size;
    }

    @Override
    public boolean isEmpty() {
        return size == 0;
    }

    @Override
    public Integer get(int index) {
        if (index < 0 || index >= size) {
            throw new IndexOutOfBoundsException("index:" + index + "IndexOutOfBoundsException");
        }
        return elements[index];
    }

    @Override
    public Integer set(int index, Integer element) {
        Integer old = elements[index];
        elements[index] = element;
        return old;
    }

    @Override
    public Integer remove(int index) {
        return null;
    }

    @Override
    public int indexOf(Integer element) {
        for (int i = 0; i < size; i++) {
            if (elements[i] == element) {
                return i;
            }
        }
        return -1;
    }

    @Override
    public void clear() {
        size = 0;
    }

    @Override
    public boolean contains(Integer element) {
        return false;
    }

    @Override
    public void add(Integer element) {

    }

    @Override
    public void add(int index, Integer element) {

    }
}
